﻿<!DOCTYPE html>
<html>
<!-- 安委会-编辑 -->

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
        <script src="/static/js/common.js"></script>

</head>

<body>
    <div id="app" class="popupW50" v-cloak>
        <el-form label-position="right" :model="Form" status-icon :rules="rules" ref="ruleForm" label-width="100px"
                 size="mini">
            <el-row>
                <el-col :span="11" >
                    <div class="elst-select-mini">
                        <el-form-item prop="name">
                            <el-input type="text" v-model="Form.name" autocomplete="off" size="mini">
                                <template slot="prepend">
                                    {{HistoricalinquiriesonminutesofSecurityCommitteemeetings.Conferencetitle+mark.m}}
                                </template>
                            </el-input>
                            <span class="iputLineMust" v-if="!Form.name">
                                <!-- 必填项添加 -->
                                <img src="/static/images/exclamation.png" alt="">
                            </span>
                            <!--<span class="iputLineMust" v-if="Form.Conferencetitle.length<=0">
         必填项添加
        <img src="/static/images/exclamation.png" alt="">
    </span>-->

                        </el-form-item>
                    </div>
                </el-col>
                <el-col :span="11" offset="2">
                    <div class="elst-select-mini" style="margin-left: -100px">
                        <el-form-item prop="dateofaddition">
                            <el-input size="mini">
                                <template slot="prepend">
                                    {{HistoricalinquiriesonminutesofSecurityCommitteemeetings.Dateofaddition+mark.m}}
                                </template>
                                <el-date-picker slot="suffix" v-model="Form.dateofaddition" type="date" size="mini"
                                                format="yyyy-MM-dd" value-format="yyyy-MM-dd" placeholder="选择时间">
                                </el-date-picker>
                            </el-input>
                            <span class="iputLineMust" v-if="!Form.dateofaddition">
                                <!-- 必填项添加 -->
                                <img src="/static/images/exclamation.png" alt="">
                            </span>
                        </el-form-item>
                    </div>
                 
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="24">
                    <div class="elst-select-mini">
                        <el-form-item>
                            <div class="el-input--mini el-input-group">
                                <div class="el-input-group__prepend">
                                    {{HistoricalinquiriesonminutesofSecurityCommitteemeetings.Conferencecontent+mark.m}}
                                </div>
                                <el-input class="el-textarea__inner" type="textarea" v-model="Form.conferencecontent"
                                          autocomplete="off"></el-input>
                                <span class="iputLineMust" v-if="!Form.conferencecontent">
                                    <!-- 必填项添加 -->
                                    <img src="/static/images/exclamation.png" alt="">
                                </span>
                            </div>
                        </el-form-item>
                    </div>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="24">
                    <div class="elst-select-mini">
                        <el-form-item prop="attachment">

                            <label for="Trainingtime" class="el-form-item__label"
                                   style="width: 150px;">{{HistoricalinquiriesonminutesofSecurityCommitteemeetings.file+mark.m}}</label>

                            <span>
                                <btn-uploadfile-input v-model="Form.attachmentName" text="上传"
                                                      :fileid="Form.attachmentId" :filename="Form.attachmentName" :showdownload="true"
                                                      @success="attachmentHandle"></btn-uploadfile-input>

                            </span>
                        </el-form-item>
                    </div>

                    <!--上报部门-->
                </el-col>
                <!--<el-col :span="20">
            <div class="elst-select-mini">
                <el-form-item>
                    <el-input disabled type="text" v-model="Form.file" autocomplete="off" size="mini"
                              readonly>
                        <template slot="prepend">
                            {{HistoricalinquiriesonminutesofSecurityCommitteemeetings.file+mark.m}}
                        </template>
                    </el-input>
                </el-form-item>
            </div>
        </el-col>
        <el-col :span="4">
            <el-upload class="fl ml10" class="upload-demo" ref="Attachmentupload"
                       action="/api/File/UpdateFile" multiple="true" :on-preview="handlePreview"
                       :on-remove="handleRemove" :before-upload="fileAttachmentUploadbeforeupload"
                       :auto-upload="true" :limit="1" :show-file-list="false">
                <el-button type="primary" class="ml10" @click="btnAttachmentUpload">{{col.btnUpLoadPDF}}</el-button>
            </el-upload>
        </el-col>-->
            </el-row>

            <el-row type="flex" justify="end">
                <el-form-item>
                    <el-button type="primary" @click="onSubmitForm('ruleForm')">{{col.btnSave}}</el-button>
                    <!--<el-button type="primary" @click="onSubmitForm('ruleForm')">{{col.btnCommit}}</el-button>-->
                    <el-button type="primary" @click="parent.ListItem.dialogVisible=false">{{col.btnBack}}</el-button>
                </el-form-item>
            </el-row>
        </el-form>
    </div>
    <script type="text/javascript">
        var uploadText = "请选择上传文件";
        var app = new Vue({
            el: '#app',
            data: {
                value1: '',
                // picked : '1',
                //父业传参
                id: '',
                //获取下拉菜单frequency
                frequency: [],
                //业务表单内容
                Form: {
                    id: guidEmpty,
                    Name: '',
                    Dateofaddition: '',
                    Conferencecontent: '',
                    file: uploadText,
                    attachmentId: '',
                    attachmentName: ''

                },
                //表单验证
                rules: {
                     name: [
                         verification.NotNull,
                     ],
                     dateofaddition: [
                         verification.NotNull,
                     ],
                     conferencecontent: [
                         verification.NotNull,
                     ],


                }
            },
            methods: {
                attachmentHandle: function (response, fileid, fileName) {

                    console.log('fileid', fileid)
                    console.log('fileName', fileName)

                    this.Form.attachmentId = fileid;
                    this.Form.attachmentName = fileName;

                    console.log(' this.Form.attachmentId', this.Form.attachmentid)
                    console.log(' this.Form.attachmentName', this.Form.attachmentName)

                },
                //解決edge下select bug
                visibleChange: function (isVisible) {
                    visibleChange(isVisible)
                },
                submitFileListUpload: function () {
                    //若更换文件则将文件名字更换触发条件--先删除上一个文件,后添加一个文件
                    if (this.labelUpload != uploadText) {
                        this.$refs.Fileupload.clearFiles();
                        this.labelUpload = file.name;
                    }
                    else {

                    }
                    //this.$refs.upload.submit();
                },
                handleRemove: function (file) {
                    console.log(file);
                },
                handlePreview: function (file) {
                    console.log(file.name);
                    window.open(file.url)
                },
                //上传前文件的校验
                beforeupload: function (file) {
                    var testmsg = file.name.substring(file.name.lastIndexOf('.') + 1)
                    //将文件名称赋值到label上
                    this.labelUpload = file.name;
                    const extension = testmsg === 'xls'
                    const extension2 = testmsg === 'xlsx'
                    const isLt2M = file.size / 1024 / 1024 < 10

                    if (!extension && !extension2) {
                        this.$message({
                            message: '上传文件只能是 xls、xlsx格式!',
                            type: 'warning'
                        });
                    }
                    if (!isLt2M) {
                        this.$message({
                            message: '上传文件大小不能超过 10MB!',
                            type: 'warning'
                        });
                    }
                    if (extension || extension2 && isLt2M)
                        submitUpload(this, 'upload')
                    return extension || extension2 && isLt2M
                },
                //上传附件文件的校验
                fileAttachmentUploadbeforeupload: function (file) {
                    var testmsg = file.name.substring(file.name.lastIndexOf('.') + 1)
                    //将附件名赋值到label上
                    this.Form.file = file.name;
                    const extension = testmsg === 'rar'
                    const extension2 = testmsg === 'zip'
                    const isLt2M = file.size / 1024 / 1024 < 10
                    if (!extension && !extension2) {
                        this.$message({
                            message: '上传文件只能是 rar、zip格式!',
                            type: 'warning'
                        });
                    }
                    if (!isLt2M) {
                        this.$message({
                            message: '上传文件大小不能超过 10MB!',
                            type: 'warning'
                        });
                    }
                    if (extension || extension2 && isLt2M)
                        submitUpload(this, 'upload')
                    return extension || extension2 && isLt2M
                },
                btnAttachmentUpload: function () {
                    //若更换文件则将文件名字更换触发条件--先删除上一个文件,后添加一个文件
                    if (this.fileAttachmentUpload != uploadText) {
                        this.$refs.Attachmentupload.clearFiles();
                        this.fileAttachmentUpload = file.name;
                    }
                    else {

                    }
                    this.$refs.Attachmentupload.submit();
                },
                //提交数据
                onSubmitForm: function (formName) {
                    var mythis = this;
                    this.$refs[formName].validate(function (valid) {
                        //验证通过
                        if (valid) {
                            onSubmitForm(this, '/api/ZB_SafetyMeeting/Save', mythis.Form);
                        } else {
                            //验证失败
                            return false;
                        }
                    });
                },
                getData: function () {
                    getData(this, '/api/ZB_SafetyMeeting/get?id=' + this.id);
                    this.Form.frequency = this.Form.frequency + "";
                },
            },
            mounted: function () {

                this.id = getUrlParam("id");
                this.getData();
                //获取下拉菜单内容
             //   this.frequency = getDicData('56');
                //初始化数据
                // this.GetPageData(1);
                //列表高度自适应
                tablehigh(this);

            },

        });
    </script>
</body>

</html>